package com.corona.game;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.TextureData;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.corona.Game;
import com.corona.game.util.SpriteProxy;
import com.corona.game.util.TextureCache;
import com.sun.jna.platform.win32.COM.tlb.imp.TlbBase;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.Reader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import org.lwjgl.egl.EXTCreateContextRobustness;

/* loaded from: pokewilds.jar:com/pkmngen/game/Specie.class */
public class Specie {
    public static HashMap<String, Texture> textures = new HashMap<>();
    public static HashMap<String, Map<String, String>> gen2Evos = new HashMap<>();
    public static HashMap<String, Map<Integer, String[]>> gen2Attacks = new HashMap<>();
    public static HashMap<String, ArrayList<String>> eggMoves = new HashMap<>();
    public static ArrayList<String> creditedPokemon = new ArrayList<>();
    public static HashMap<String, Specie> species;
    String name;
    String dexNumber;
    String genderRatio;
    String[] eggGroups;
    int baseHappiness;
    int eggCycles;
    ArrayList<String> types;
    String growthRateGroup;
    Map<Integer, String[]> learnSet;
    ArrayList<String> hms;
    Map<String, Integer> baseStats;
    Pokemon.Generation generation;
    String modNickname;
    public Integer cryLengthInFrames;
    SpriteProxy sprite;
    SpriteProxy backSprite;
    SpriteProxy spriteShiny;
    SpriteProxy backSpriteShiny;
    static SpriteProxy spriteGhost;
    static SpriteProxy spriteEgg;
    static SpriteProxy backSpriteEgg;
    ArrayList<SpriteProxy> introAnim;
    ArrayList<SpriteProxy> introAnimShiny;
    static ArrayList<SpriteProxy> introAnimGhost;
    static ArrayList<SpriteProxy> introAnimEgg;
    public int spriteOffsetY;
    public Map<String, Sprite> standingSprites;
    public Map<String, Sprite> movingSprites;
    public Map<String, Sprite> altMovingSprites;
    ArrayList<Sprite> avatarSprites;
    public Map<String, Sprite> standingSpritesEgg;
    public Map<String, Sprite> movingSpritesEgg;
    public Map<String, Sprite> altMovingSpritesEgg;
    ArrayList<Sprite> avatarSpritesEgg;
    public Map<String, Sprite> surfSprites;
    public Map<String, Sprite> surfMovingSprites;
    public int harvestTimerMax;
    public ArrayList<String> harvestables;
    public ArrayList<String> habitats;

    static {
        for (String t : new String[]{"aggron", "aron", "exploud", "gardevoir", "hariyama", "kirlia", "lairon", "lombre", "lotad", "loudred", "ludicolo", "makuhita", "ralts", "taillow", "swellow", "whismur", "poochyena", "mightyena", "wingull", "pelipper", "shroomish", "breloom", "surskit", "masquerain", "sableye", "numel", "camerupt", "sylveon", "glaceon", "leafeon", "zigzagoon", "linoone", "maractus", "araichu", "phantump", "appletun", "trevenant", "pikipek", "trumbeak", "toucannon", "amarowak", "volbeat", "plusle", "minun", "floatzel", "buizel", "noibat", "noivern", "honchkrow", "gallade", "absol", "torkoal", "trapinch", "vibrava", "flygon", "duskull", "dusclops", "dusknoir", "skorupi", "drapion", "cacnea", "cacturne", "shinx", "luxio", "luxray", "gible", "gabite", "garchomp", "drifloon", "drifblim", "feebas", "milotic", "snorunt", "glalie", "froslass", "solrock", "lunatone", "beldum", "metang", "metagross", "magmortar", "electivire", "mamoswine", "mismagius", "rhyperior", "weavile", "yanmega", "anorith", "armaldo", "shieldon", "bastiodon", "lileep", "cradily", "cranidos", "rampardos", "chingling", "chimecho", "shuppet", "banette", "spiritomb", "riolu", "lucario", "aexeggutor", "dwebble", "crustle", "litwick", "lampent", "chandelure", "corphish", "crawdaunt", "mimikyu", "regieleki", "regidrago", "registeel", "regirock", "regice", "regigigas", "bronzor", "bronzong", "darumaka", "darmanitan", "darmanitanzen", "elgyem", "beheeyem", "sandile", "krokorok", "krookodile", "cutiefly", "ribombee", "combee", "combee_female", "vespiquen", "nosepass", "sigilyph", "snover", "abomasnow", "goomy", "swirlix", "zigzagoon", "larvesta", "volcarona", "mantyke", "phione", "finneon", "probopass", "gcorsola", "gyamask", "runerigus", "straigar", "ambipom", "gdarumaka", "gdarmanitan", "gdarmanitanzen", "pumpkaboo", "carvanha", "sharpedo", "sandygast", "palossand", "luvdisc", "duraludon", "snom", "jirachi", "frosmoth", "cosmog", "cosmoem", "deino", "zweilous", "hydreigon", "applin", "stonjourner"}) {
            creditedPokemon.add(t);
        }
        if (Game.fairyTypeEnabled) {
            for (String t2 : new String[]{"azurill", "marill", "azumarill"}) {
                creditedPokemon.add(t2);
            }
        }
        species = new HashMap<>();
        if (!textures.containsKey("egg_front")) {
            textures.put("egg_front", TextureCache.get(Gdx.files.internal("pokemon/pokemon/egg/front.png")));
            textures.put("egg_back", TextureCache.get(Gdx.files.internal("pokemon/pokemon/egg/back.png")));
        }
        if (!textures.containsKey("ghost_front")) {
            textures.put("ghost_front", TextureCache.get(Gdx.files.internal("pokemon/credited/pokemon/ghost/front.png")));
        }
        Texture pokemonText = textures.get("egg_front");
        int height = pokemonText.getWidth();
        spriteEgg = new SpriteProxy(pokemonText, 0, 0, height, height);
        backSpriteEgg = new SpriteProxy(textures.get("egg_back"), 0, 0, 48, 48);
        Texture pokemonText2 = textures.get("ghost_front");
        int height2 = pokemonText2.getWidth();
        spriteGhost = new SpriteProxy(pokemonText2, 0, 0, height2, height2);
        introAnimGhost = new ArrayList<>();
        introAnimEgg = new ArrayList<>();
        try {
            int setrepeat = 0;
            ArrayList<String> lines = Game.readLines(Gdx.files.internal("pokemon/credited/pokemon/ghost/anim.asm"));
            int i = 0;
            while (i < lines.size()) {
                String line = lines.get(i);
                if (line.contains("setrepeat")) {
                    setrepeat = Integer.valueOf(line.split("setrepeat ")[1]).intValue();
                } else if (line.contains("frame")) {
                    String[] vals = line.split("frame ")[1].split(", ");
                    int numFrames = Integer.valueOf(vals[1].trim()).intValue();
                    int frame = Integer.valueOf(vals[0]).intValue();
                    for (int j = 0; j < numFrames; j++) {
                        introAnimGhost.add(new SpriteProxy(textures.get("ghost_front"), 0, height2 * frame, height2, height2));
                    }
                } else if (line.contains("dorepeat") && setrepeat != 0) {
                    i = Integer.valueOf(line.split("dorepeat ")[1]).intValue();
                    setrepeat--;
                }
                i++;
            }
            int setrepeat2 = 0;
            ArrayList<String> lines2 = Game.readLines(Gdx.files.internal("pokemon/pokemon/egg/anim.asm"));
            int i2 = 0;
            while (i2 < lines2.size()) {
                String line2 = lines2.get(i2);
                if (line2.contains("setrepeat")) {
                    setrepeat2 = Integer.valueOf(line2.split("setrepeat ")[1]).intValue();
                } else if (line2.contains("frame")) {
                    String[] vals2 = line2.split("frame ")[1].split(", ");
                    int numFrames2 = Integer.valueOf(vals2[1]).intValue();
                    int frame2 = Integer.valueOf(vals2[0]).intValue();
                    for (int j2 = 0; j2 < numFrames2; j2++) {
                        Texture pokemonText3 = textures.get("egg_front");
                        int height3 = pokemonText3.getWidth();
                        introAnimEgg.add(new SpriteProxy(pokemonText3, 0, height3 * frame2, height3, height3));
                    }
                } else if (line2.contains("dorepeat") && setrepeat2 != 0) {
                    i2 = Integer.valueOf(line2.split("dorepeat ")[1]).intValue();
                    setrepeat2--;
                }
                i2++;
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e2) {
            e2.printStackTrace();
        }
    }

    public int cryLengthInFrames() {
        if (this.cryLengthInFrames == null) {
            this.cryLengthInFrames = Integer.valueOf(cryLengthInFrames("pokemon/cries/" + this.dexNumber));
        }
        return this.cryLengthInFrames.intValue();
    }

    public static int cryLengthInFrames(String path) {
        try {
            String line = new BufferedReader(Game.checkForMods(path + ".length").reader()).readLine();
            if (line != null) {
                return ((int) (Float.valueOf(line).floatValue() * 60.0f)) + 1;
            }
            return 0;
        } catch (IOException e) {
            e.printStackTrace();
            return 0;
        } catch (NumberFormatException e2) {
            e2.printStackTrace();
            return 0;
        }
    }

    public Specie(String name) {
        this(name, Pokemon.Generation.CRYSTAL);
    }

    Specie(String name, Pokemon.Generation gen) {
        this.eggGroups = new String[2];
        this.baseHappiness = 70;
        this.eggCycles = 0;
        this.growthRateGroup = "";
        this.learnSet = new HashMap();
        this.hms = new ArrayList<>();
        this.baseStats = new HashMap();
        this.modNickname = null;
        this.cryLengthInFrames = null;
        this.spriteOffsetY = 0;
        this.standingSprites = new HashMap();
        this.movingSprites = new HashMap();
        this.altMovingSprites = new HashMap();
        this.avatarSprites = new ArrayList<>();
        this.standingSpritesEgg = new HashMap();
        this.movingSpritesEgg = new HashMap();
        this.altMovingSpritesEgg = new HashMap();
        this.avatarSpritesEgg = new ArrayList<>();
        this.surfSprites = null;
        this.surfMovingSprites = null;
        this.harvestTimerMax = 9000;
        this.harvestables = new ArrayList<>();
        this.harvestables.add("manure");
        this.habitats = new ArrayList<>();
        this.habitats.add("green");
        init(name, gen);
    }

    public void init(String n, Pokemon.Generation generation) {
        this.name = n.toLowerCase(Locale.ROOT);
        this.generation = generation;
        this.types = new ArrayList<>();
        this.learnSet = new HashMap();
        if (generation.equals(Pokemon.Generation.CRYSTAL)) {
            this.dexNumber = Pokemon.nameToIndex(this.name);
            loadFromAsm();
            loadOverworldSprites();
            if (this.name.equals("sneasel") || this.name.equals("weavile") || this.name.equals("scyther") || this.name.equals("scizor") || this.name.equals("krabby") || this.name.equals("kingler") || this.name.equals("pinsir") || this.name.equals("corphish") || this.name.equals("crawdaunt") || this.name.equals("absol")) {
                this.hms.add("CUT");
            }
            if (this.name.equals("riolu") || this.name.equals("lucario")) {
                this.hms.add("SMASH");
            }
            if (this.name.equals("smeargle")) {
                this.hms.add("PAINT");
            }
            if (this.types.contains("GROUND") || this.name.contains("tyranitar")) {
                this.hms.add("DIG");
            }
            if (this.types.contains("ELECTRIC") || this.name.contains("porygon")) {
                this.hms.add("POWER");
            }
            if (this.types.contains("GRASS")) {
                this.hms.add("CUT");
            }
            if (this.types.contains("ROCK")) {
                this.hms.add("SMASH");
            }
            if (this.types.contains("FIGHTING")) {
                this.hms.add("BUILD");
            }
            if (this.types.contains("FAIRY")) {
                this.hms.add("CHARM");
            }
            if (this.types.contains("POISON")) {
                this.hms.add("REPEL");
            }
            if (this.types.contains("FIRE") || this.name.equals("chinchou") || this.name.equals("lanturn") || this.name.equals("mareep") || this.name.equals("flaaffy") || this.name.equals("ampharos") || this.name.equals("volbeat")) {
                this.hms.add("FLASH");
            }
            if (this.name.equals("squirtle") || this.name.equals("wartortle") || this.name.equals("blastoise") || this.name.equals("slowpoke") || this.name.equals("slowbro") || this.name.equals("slowking") || this.name.equals("seel") || this.name.equals("dewgong") || this.name.equals("drowzee") || this.name.equals("hypno") || this.name.equals("cubone") || this.name.equals("marowak") || this.name.equals("kangaskhan") || this.name.equals("munchlax") || this.name.equals("snorlax") || this.name.equals("snubbull") || this.name.equals("granbull") || this.name.equals("miltank") || this.name.equals("aron") || this.name.equals("lairon") || this.name.equals("aggron") || this.name.equals("bagon") || this.name.equals("shelgon") || this.name.equals("salamence") || this.name.equals("bidoof") || this.name.equals("bibarel") || this.name.equals("cranidos") || this.name.equals("rampardos") || this.name.equals("darumaka") || this.name.equals("darmanitan") || this.name.equals("darmanitanzen") || this.name.equals("scraggy") || this.name.equals("scrafty") || this.name.equals("elgyem") || this.name.equals("beheeyem") || this.name.equals("scorbunny") || this.name.equals("raboot") || this.name.equals("cinderace") || this.name.equals("wooloo") || this.name.equals("dubwool") || this.name.equals("obstagoon") || this.name.equals("nidoran_m") || this.name.equals("nidoran_f") || this.name.equals("nidorina") || this.name.equals("nidorino") || this.name.equals("nidoking") || this.name.equals("nidoqueen") || this.name.equals("whismur") || this.name.equals("loudred") || this.name.equals("exploud") || this.name.equals("heracross") || this.name.equals("shieldon") || this.name.equals("bastiodon") || this.name.equals("teddiursa") || this.name.equals("ursaring") || this.name.equals("tauros")) {
                this.hms.add("HEADBUTT");
            }
            if (this.name.equals("stantler") || this.name.equals("ponyta") || this.name.equals("arcanine") || this.name.equals("donphan") || this.name.equals("girafarig") || this.name.equals("houndoom") || this.name.equals("rapidash") || this.name.equals("tauros") || this.name.equals("ninetales") || this.name.equals("piloswine") || this.name.equals("mamoswine") || this.name.equals("dodrio") || this.name.equals("mightyena") || this.name.equals("kangaskhan") || this.name.equals("persian") || this.name.equals("onix") || this.name.equals("steelix") || this.name.equals("haunter") || this.name.equals("rhyhorn") || this.name.equals("rhydon") || this.name.equals("rhyperior") || this.name.equals("bastiodon") || this.name.equals("camerupt") || this.name.equals("probopass") || this.name.equals("luxray") || this.name.equals("absol")) {
                this.hms.add("RIDE");
            }
            if (this.name.equals("pidgeot") || this.name.equals("aerodactyl") || this.name.equals("charizard") || this.name.equals("dragonair") || this.name.equals("dragonite") || this.name.equals("salamence") || this.name.equals("ho_oh") || this.name.equals("lugia") || this.name.equals("skarmory") || this.name.equals("articuno") || this.name.equals("zapdos") || this.name.equals("moltres") || this.name.equals("crobat") || this.name.equals("noctowl") || this.name.equals("xatu") || this.name.equals("flygon") || this.name.equals("togekiss") || this.name.equals("swellow") || this.name.equals("pelipper") || this.name.equals("altaria") || this.name.equals("rayquaza") || this.name.equals("drifblim") || this.name.equals("honchkrow") || this.name.equals("yanmega") || this.name.equals("garchomp") || this.name.equals("volcarona") || this.name.equals("fearow") || this.name.equals("mewtwo") || this.name.equals("mantine") || this.name.equals("toucannon") || this.name.equals("noivern")) {
                this.hms.add("FLY");
            }
            if (this.types.contains("DARK")) {
                this.hms.add("ATTACK");
            }
            if (this.types.contains("PSYCHIC")) {
                this.hms.add("TELEPORT");
            }
            boolean hasEvo = !gen2Evos.get(this.name).isEmpty();
            if (this.name.equals("rhydon") || this.name.equals("rhyperior") || this.name.equals("pikachu") || this.name.equals("raichu") || this.name.equals("araichu") || this.name.equals("aggron") || (this.types.contains("WATER") && !hasEvo)) {
                this.hms.add("SURF");
            }
            initHabitatValues();
        }
    }

    void loadFromAsm() {
        String newName = this.name;
        if (this.name.contains("unown")) {
            newName = "unown";
        }
        if (this.name.equals("combee_female")) {
            newName = "combee";
        }
        String path = "";
        if (creditedPokemon.contains(newName)) {
            path = "credited/";
        }
        boolean doingMod = true;
        FileHandle file = Gdx.files.local("mods/pokemon/" + newName + "/base_stats.asm");
        if (!file.exists()) {
            doingMod = false;
            file = Gdx.files.internal("pokemon/" + path + "base_stats/" + newName + ".asm");
        }
        try {
            Reader reader = file.reader();
            BufferedReader br = new BufferedReader(reader);
            int lineNum = 0;
            while (true) {
                String line = br.readLine();
                if (line == null) {
                    break;
                }
                if (doingMod && lineNum == 0) {
                    this.modNickname = line.split("db")[1].split(";")[0].trim();
                }
                if (lineNum == 2) {
                    String[] stats = line.split("db")[1].split(",");
                    this.baseStats.put("hp", Integer.valueOf(stats[0].replace(" ", "")));
                    this.baseStats.put("attack", Integer.valueOf(stats[1].replace(" ", "")));
                    this.baseStats.put("defense", Integer.valueOf(stats[2].replace(" ", "")));
                    this.baseStats.put("speed", Integer.valueOf(stats[3].replace(" ", "")));
                    this.baseStats.put("specialAtk", Integer.valueOf(stats[4].replace(" ", "")));
                    this.baseStats.put("specialDef", Integer.valueOf(stats[5].replace(" ", "")));
                } else if (lineNum == 5) {
                    String[] types = line.split("db ")[1].split(" ; ")[0].split(", ");
                    String prevType = "NORMAL";
                    for (String type : types) {
                        if (Game.fairyTypeEnabled || !type.equals("FAIRY")) {
                            prevType = type;
                            this.types.add(type);
                        }
                    }
                    if (this.types.isEmpty()) {
                        this.types.add("NORMAL");
                    }
                    if (this.types.size() < 2) {
                        this.types.add(prevType);
                    }
                } else if (lineNum == 6) {
                    this.baseStats.put("catchRate", Integer.valueOf(line.split("db ")[1].split(" ;")[0]));
                } else if (lineNum == 7) {
                    this.baseStats.put("baseExp", Integer.valueOf(line.split("db ")[1].split(" ;")[0]));
                } else if (lineNum == 9) {
                    this.genderRatio = line.split("db ")[1].split(" ;")[0];
                } else if (lineNum == 11) {
                    this.eggCycles = Integer.valueOf(line.split("db ")[1].split(" ;")[0]).intValue();
                } else if (lineNum == 15) {
                    this.growthRateGroup = line.split("db ")[1].split(" ;")[0];
                } else if (lineNum == 16) {
                    this.eggGroups = line.split("dn ")[1].split(" ;")[0].split(", ");
                    for (int i = 0; i < this.eggGroups.length; i++) {
                        if (this.eggGroups[i].equals("EGG_GROUND")) {
                            this.eggGroups[i] = "EGG_FIELD";
                        }
                    }
                }
                lineNum++;
            }
            reader.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e2) {
            e2.printStackTrace();
        }
        if (!textures.containsKey(this.name + "_front")) {
            FileHandle file2 = Gdx.files.local("mods/pokemon/" + this.name + "/front.png");
            if (!file2.exists()) {
                file2 = Gdx.files.internal("pokemon/" + path + "pokemon/" + this.name + "/front.png");
            }
            Texture text = TextureCache.get(file2);
            if (this.name.contains("unown") && !this.name.equals("unown_!") && !this.name.equals("unown_qmark")) {
                TextureData temp = text.getTextureData();
                if (!temp.isPrepared()) {
                    temp.prepare();
                }
                Pixmap currPixmap = temp.consumePixmap();
                Pixmap newPixmap = new Pixmap(text.getWidth(), text.getHeight(), Pixmap.Format.RGBA8888);
                newPixmap.setColor(new Color(0.0f, 0.0f, 0.0f, 0.0f));
                newPixmap.fill();
                int i2 = 0;
                int j = 0;
                while (j < text.getHeight()) {
                    if (i2 > text.getWidth()) {
                        i2 = -1;
                        j++;
                    } else {
                        Color color = new Color(currPixmap.getPixel(i2, j));
                        newPixmap.drawPixel(i2, j, Color.rgba8888(color.a, color.a, color.a, 1.0f));
                    }
                    i2++;
                }
                text = new Texture(newPixmap);
            }
            textures.put(this.name + "_front", text);
            Color normalColor1 = null;
            Color normalColor2 = new Color();
            Color shinyColor1 = null;
            Color shinyColor2 = new Color();
            if (creditedPokemon.contains(newName)) {
                path = "credited/";
            }
            try {
                FileHandle file3 = Gdx.files.local("mods/pokemon/" + newName + "/shiny.pal");
                if (!file3.exists()) {
                    file3 = Gdx.files.internal("pokemon/" + path + "pokemon/" + newName + "/shiny.pal");
                } else {
                    System.out.println("Found mods for: " + newName);
                }
                Reader reader2 = file3.reader();
                BufferedReader br2 = new BufferedReader(reader2);
                while (true) {
                    String line2 = br2.readLine();
                    if (line2 == null) {
                        break;
                    } else if (line2.contains("RGB")) {
                        String[] vals = line2.split("\tRGB ")[1].split(", ");
                        if (shinyColor1 == null) {
                            shinyColor1 = new Color();
                            shinyColor1.r = (Float.valueOf(vals[0]).floatValue() * 8.0f) / 256.0f;
                            shinyColor1.g = (Float.valueOf(vals[1]).floatValue() * 8.0f) / 256.0f;
                            shinyColor1.b = (Float.valueOf(vals[2]).floatValue() * 8.0f) / 256.0f;
                            shinyColor1.a = 1.0f;
                        } else {
                            shinyColor2.r = (Float.valueOf(vals[0]).floatValue() * 8.0f) / 256.0f;
                            shinyColor2.g = (Float.valueOf(vals[1]).floatValue() * 8.0f) / 256.0f;
                            shinyColor2.b = (Float.valueOf(vals[2]).floatValue() * 8.0f) / 256.0f;
                            shinyColor2.a = 1.0f;
                        }
                    }
                }
                reader2.close();
                SpriteProxy tempSprite = new SpriteProxy(textures.get(this.name + "_front"), 0, 0, text.getWidth(), text.getWidth());
                if (tempSprite.color1.r + tempSprite.color1.g + tempSprite.color1.b == tempSprite.color2.r + tempSprite.color2.g + tempSprite.color2.b) {
                    System.out.println("TODO: verify that this Pokemon's shiny is correct: " + this.name);
                }
                normalColor1 = new Color();
                normalColor1.r = tempSprite.color1.r * 32.0f;
                normalColor1.g = tempSprite.color1.g * 32.0f;
                normalColor1.b = tempSprite.color1.b * 32.0f;
                normalColor2 = new Color();
                normalColor2.r = tempSprite.color2.r * 32.0f;
                normalColor2.g = tempSprite.color2.g * 32.0f;
                normalColor2.b = tempSprite.color2.b * 32.0f;
            } catch (FileNotFoundException e3) {
                e3.printStackTrace();
            } catch (IOException e4) {
                e4.printStackTrace();
            }
            TextureData temp2 = text.getTextureData();
            if (!temp2.isPrepared()) {
                temp2.prepare();
            }
            Pixmap currPixmap2 = temp2.consumePixmap();
            Pixmap newPixmap2 = new Pixmap(text.getWidth(), text.getHeight(), Pixmap.Format.RGBA8888);
            newPixmap2.setColor(new Color(0.0f, 0.0f, 0.0f, 0.0f));
            newPixmap2.fill();
            int i3 = 0;
            int j2 = 0;
            while (j2 < text.getHeight()) {
                if (i3 > text.getWidth()) {
                    i3 = -1;
                    j2++;
                } else {
                    Color color2 = new Color(currPixmap2.getPixel(i3, j2));
                    if (((int) (color2.r * 32.0f)) == ((int) normalColor1.r) && ((int) (color2.g * 32.0f)) == ((int) normalColor1.g) && ((int) (color2.b * 32.0f)) == ((int) normalColor1.b)) {
                        color2 = shinyColor1;
                    } else if (((int) (color2.r * 32.0f)) == ((int) normalColor2.r) && ((int) (color2.g * 32.0f)) == ((int) normalColor2.g) && ((int) (color2.b * 32.0f)) == ((int) normalColor2.b)) {
                        color2 = shinyColor2;
                    }
                    newPixmap2.drawPixel(i3, j2, Color.rgba8888(color2.r, color2.g, color2.b, color2.a));
                }
                i3++;
            }
            textures.put(this.name + "_front_shiny", TextureCache.get(newPixmap2));
            FileHandle file4 = Gdx.files.local("mods/pokemon/" + this.name + "/back.png");
            if (!file4.exists()) {
                file4 = Gdx.files.internal("pokemon/" + path + "pokemon/" + this.name + "/back.png");
            }
            Texture text2 = TextureCache.get(file4);
            textures.put(this.name + "_back", text2);
            TextureData temp3 = text2.getTextureData();
            if (!temp3.isPrepared()) {
                temp3.prepare();
            }
            Pixmap currPixmap3 = temp3.consumePixmap();
            Pixmap newPixmap3 = new Pixmap(text2.getWidth(), text2.getHeight(), Pixmap.Format.RGBA8888);
            newPixmap3.setColor(new Color(0.0f, 0.0f, 0.0f, 0.0f));
            newPixmap3.fill();
            int i4 = 0;
            int j3 = 0;
            while (j3 < text2.getHeight()) {
                if (i4 > text2.getWidth()) {
                    i4 = -1;
                    j3++;
                } else {
                    Color color3 = new Color(currPixmap3.getPixel(i4, j3));
                    if (((int) (color3.r * 32.0f)) == ((int) normalColor1.r) && ((int) (color3.g * 32.0f)) == ((int) normalColor1.g) && ((int) (color3.b * 32.0f)) == ((int) normalColor1.b)) {
                        color3 = shinyColor1;
                    } else if (((int) (color3.r * 32.0f)) == ((int) normalColor2.r) && ((int) (color3.g * 32.0f)) == ((int) normalColor2.g) && ((int) (color3.b * 32.0f)) == ((int) normalColor2.b)) {
                        color3 = shinyColor2;
                    }
                    newPixmap3.drawPixel(i4, j3, Color.rgba8888(color3.r, color3.g, color3.b, color3.a));
                }
                i4++;
            }
            textures.put(this.name + "_back_shiny", TextureCache.get(newPixmap3));
        }
        Texture pokemonText = textures.get(this.name + "_front");
        int height = pokemonText.getWidth();
        this.sprite = new SpriteProxy(pokemonText, 0, 0, height, height);
        this.backSprite = new SpriteProxy(textures.get(this.name + "_back"), 0, 0, 48, 48);
        Texture pokemonText2 = textures.get(this.name + "_front_shiny");
        int height2 = pokemonText2.getWidth();
        this.spriteShiny = new SpriteProxy(pokemonText2, 0, 0, height2, height2);
        this.backSpriteShiny = new SpriteProxy(textures.get(this.name + "_back_shiny"), 0, 0, 48, 48);
        this.introAnim = new ArrayList<>();
        this.introAnimShiny = new ArrayList<>();
        try {
            FileHandle file5 = Gdx.files.local("mods/pokemon/" + this.name + "/anim.asm");
            if (!file5.exists()) {
                file5 = Gdx.files.internal("pokemon/" + path + "pokemon/" + this.name + "/anim.asm");
            }
            int setrepeat = 0;
            ArrayList<String> lines = Game.readLines(file5);
            int i5 = 0;
            while (i5 < lines.size()) {
                String line3 = lines.get(i5);
                if (line3.contains("setrepeat")) {
                    setrepeat = Integer.valueOf(line3.split("setrepeat ")[1]).intValue();
                } else if (line3.contains("frame")) {
                    String[] vals2 = line3.split("frame ")[1].split(", ");
                    int numFrames = Integer.valueOf(vals2[1].trim()).intValue();
                    int frame = Integer.valueOf(vals2[0]).intValue();
                    for (int j4 = 0; j4 < numFrames; j4++) {
                        this.introAnim.add(new SpriteProxy(textures.get(this.name + "_front"), 0, height2 * frame, height2, height2));
                        this.introAnimShiny.add(new SpriteProxy(textures.get(this.name + "_front_shiny"), 0, height2 * frame, height2, height2));
                    }
                } else if (line3.contains("dorepeat") && setrepeat != 0) {
                    i5 = Integer.valueOf(line3.split("dorepeat ")[1]).intValue();
                    setrepeat--;
                }
                i5++;
            }
        } catch (FileNotFoundException e5) {
            e5.printStackTrace();
        } catch (IOException e6) {
            e6.printStackTrace();
        }
        if (creditedPokemon.contains(newName)) {
            path = "credited/";
        }
        if (!gen2Attacks.containsKey(newName) || !gen2Evos.containsKey(newName)) {
            Map<Integer, String[]> attacks = new HashMap<>();
            Map<String, String> evos = new HashMap<>();
            boolean inSection = true;
            boolean doingMod2 = false;
            FileHandle file6 = Gdx.files.local("mods/pokemon/" + newName + "/evos_attacks.asm");
            if (!file6.exists()) {
                inSection = false;
                doingMod2 = true;
                file6 = Gdx.files.internal("pokemon/" + path + "evos_attacks.asm");
            }
            try {
                ArrayList<String> lines2 = Game.readLines(file6);
                for (int i6 = 0; i6 < lines2.size(); i6++) {
                    String line4 = lines2.get(i6);
                    if (line4.toLowerCase(Locale.ROOT).equals(newName + "evosattacks:")) {
                        inSection = true;
                    } else if (inSection && !line4.contains(";")) {
                        if (doingMod2 && line4.contains("EVOLVE")) {
                            String[] vals3 = line4.split(", ");
                            String baseMon = Pokemon.baseSpecies.get(newName);
                            if (baseMon == null) {
                                baseMon = newName;
                            }
                            Pokemon.baseSpecies.put(vals3[2].toLowerCase(Locale.ROOT), baseMon);
                        }
                        if (line4.contains("EVOLVE_LEVEL")) {
                            String[] vals4 = line4.split(", ");
                            evos.put(vals4[1], vals4[2].toLowerCase(Locale.ROOT));
                        } else if (line4.contains("EVOLVE_ITEM") || line4.contains("EVOLVE_TRADE") || line4.contains("EVOLVE_HAPPINESS") || line4.contains("EVOLVE_MOVE") || line4.contains("EVOLVE_INPARTY") || line4.contains("EVOLVE_STAT")) {
                            String[] vals5 = line4.split(", ");
                            evos.put(vals5[1].toLowerCase(Locale.ROOT).replace("_", " "), vals5[2].toLowerCase(Locale.ROOT));
                        } else if (!line4.contains(TlbBase.TAB)) {
                            inSection = false;
                        } else if (!line4.contains("db 0")) {
                            String[] vals6 = line4.split(", ");
                            String attack = vals6[1].toLowerCase(Locale.ROOT).replace('_', ' ');
                            if (Pokemon.attacksImplemented.contains(attack)) {
                                int level = Integer.valueOf(vals6[0].split(" ")[1]).intValue();
                                String[] attacksArray = {attack};
                                if (attacks.containsKey(Integer.valueOf(level))) {
                                    String[] oldArray = attacks.get(Integer.valueOf(level));
                                    attacksArray = new String[oldArray.length + 1];
                                    for (int j5 = 0; j5 < oldArray.length; j5++) {
                                        attacksArray[j5] = oldArray[j5];
                                    }
                                    attacksArray[oldArray.length] = attack;
                                }
                                attacks.put(Integer.valueOf(level), attacksArray);
                            }
                        }
                    }
                }
            } catch (FileNotFoundException e7) {
                e7.printStackTrace();
            } catch (IOException e8) {
                e8.printStackTrace();
            }
            gen2Attacks.put(newName, attacks);
            if (newName.equals("combee")) {
                gen2Evos.put(newName, new HashMap());
                gen2Evos.put("combee_female", evos);
            } else {
                gen2Evos.put(this.name, evos);
            }
            FileHandle file7 = Gdx.files.local("mods/pokemon/" + newName + "/egg_moves.asm");
            if (file7.exists()) {
                try {
                    Reader reader3 = file7.reader();
                    BufferedReader br3 = new BufferedReader(reader3);
                    Pokemon.eggMoves.put(newName, new ArrayList<>());
                    while (true) {
                        String line5 = br3.readLine();
                        if (line5 == null) {
                            break;
                        } else if (!line5.contains(";") && line5.contains(TlbBase.TAB)) {
                            Pokemon.eggMoves.get(newName).add(line5.split("db ")[1].trim().toLowerCase(Locale.ROOT).replace("_", " "));
                        }
                    }
                    reader3.close();
                } catch (FileNotFoundException e9) {
                    e9.printStackTrace();
                } catch (IOException e10) {
                    e10.printStackTrace();
                }
            }
        }
        this.learnSet = gen2Attacks.get(newName);
    }

    /* JADX WARNING: Removed duplicated region for block: B:93:0x11fa  */
    /* JADX WARNING: Removed duplicated region for block: B:96:0x1230 A[RETURN] */
    /* JADX WARNING: Removed duplicated region for block: B:97:0x1231 A[Catch: FileNotFoundException -> 0x1887, IOException -> 0x188f, TRY_ENTER, TryCatch #2 {FileNotFoundException -> 0x1887, IOException -> 0x188f, blocks: (B:57:0x0ced, B:58:0x0d1a, B:60:0x0d24, B:61:0x0d33, B:63:0x0d3d, B:65:0x0d6c, B:66:0x0dcf, B:67:0x0dd8, B:71:0x0e0b, B:73:0x0faa, B:74:0x0fbe, B:76:0x1038, B:77:0x104c, B:78:0x10e4, B:80:0x10ee, B:81:0x112a, B:82:0x113f, B:84:0x1149, B:85:0x1185, B:86:0x119a, B:88:0x11a4, B:90:0x11e3, B:91:0x11e9, B:94:0x11ff, B:97:0x1231, B:99:0x1269, B:101:0x13df, B:102:0x13f3, B:104:0x146a, B:105:0x147e, B:106:0x1516, B:108:0x1520, B:109:0x155c, B:110:0x1571, B:112:0x157b, B:113:0x15b7, B:114:0x15cc, B:116:0x15d6, B:118:0x1613, B:121:0x1643, B:124:0x168c, B:125:0x1717, B:126:0x1788, B:128:0x1792, B:129:0x17ce, B:130:0x17e3, B:132:0x17ed, B:133:0x1829, B:134:0x183e, B:136:0x1848), top: B:143:0x0ced }] */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    void loadOverworldSprites() {
        /*
        // Method dump skipped, instructions count: 6293
        */
        throw new UnsupportedOperationException("Method not decompiled: com.corona.game.Specie.loadOverworldSprites():void");
    }

    void loadEggTextures(String path) {
        if (!TextureCache.eggTextures.containsKey(this.name) && !this.name.equals("phione")) {
            Texture text = TextureCache.get(Gdx.files.internal(path));
            int height = text.getWidth();
            SpriteProxy tempSprite = new SpriteProxy(text, 0, 0, height, height);
            Texture text2 = TextureCache.get(Gdx.files.internal("pokemon/egg1.png"));
            SpriteProxy tempEggSprite = new SpriteProxy(text2, 0, 0, text2.getWidth(), text2.getHeight());
            TextureData temp = text2.getTextureData();
            if (!temp.isPrepared()) {
                temp.prepare();
            }
            Pixmap currPixmap = temp.consumePixmap();
            Pixmap newPixmap = new Pixmap(text2.getWidth(), text2.getHeight(), Pixmap.Format.RGBA8888);
            newPixmap.setColor(new Color(0.0f, 0.0f, 0.0f, 0.0f));
            newPixmap.fill();
            int i = 0;
            int j = 0;
            while (j < text2.getHeight()) {
                if (i > text2.getWidth()) {
                    i = -1;
                    j++;
                } else {
                    Color color = new Color(currPixmap.getPixel(i, j));
                    if (color.r == tempEggSprite.color1.r && color.g == tempEggSprite.color1.g && color.b == tempEggSprite.color1.b) {
                        color.r = tempSprite.color1.r;
                        color.g = tempSprite.color1.g;
                        color.b = tempSprite.color1.b;
                    } else if (color.r == tempEggSprite.color2.r && color.g == tempEggSprite.color2.g && color.b == tempEggSprite.color2.b) {
                        color.r = tempSprite.color2.r;
                        color.g = tempSprite.color2.g;
                        color.b = tempSprite.color2.b;
                    }
                    newPixmap.drawPixel(i, j, Color.rgba8888(color.r, color.g, color.b, color.a));
                }
                i++;
            }
            TextureCache.eggTextures.put(this.name, TextureCache.get(newPixmap));
        } else if (!TextureCache.eggTextures.containsKey(this.name)) {
            TextureCache.eggTextures.put(this.name, TextureCache.get(Gdx.files.internal("phione-egg.png")));
        }
        Texture text3 = TextureCache.eggTextures.get(this.name);
        String[] strArr = {"up", "down", "left", "right"};
        for (String dir : strArr) {
            this.standingSpritesEgg.put(dir, new Sprite(text3, 0, 0, 16, 16));
            this.movingSpritesEgg.put(dir, new Sprite(text3, 0, 32, 16, 16));
            this.altMovingSpritesEgg.put(dir, new Sprite(text3, 0, 48, 16, 16));
        }
        Sprite hopSprite = new Sprite(text3, 0, 16, 16, 16);
        this.avatarSpritesEgg.add(this.standingSpritesEgg.get("down"));
        this.avatarSpritesEgg.add(hopSprite);
        this.avatarSpritesEgg.add(this.standingSpritesEgg.get("down"));
        this.avatarSpritesEgg.add(hopSprite);
    }

    void initHabitatValues() {
        String name = this.name.toLowerCase(Locale.ROOT);
        this.harvestables.clear();
        this.habitats.clear();
        if (this.types.contains("BUG")) {
            this.habitats.add("flower|potted");
            this.harvestables.add("silky thread");
        }
        if (this.types.contains("WATER")) {
            this.habitats.add("water");
            this.harvestables.add("hard shell");
        }
        if (this.types.contains("FLYING")) {
            this.habitats.add("tree|bush");
            this.harvestables.add("soft feather");
        }
        if (this.types.contains("ROCK")) {
            this.habitats.add("rock|statue|gym");
            this.harvestables.add("hard stone");
        }
        if (this.types.contains("FIRE")) {
            this.habitats.add("campfire|lava|soot|volcano");
            this.harvestables.add("charcoal");
        }
        if (this.types.contains("GRASS")) {
            this.habitats.add("grass");
            this.harvestables.add("miracle seed");
        }
        if (this.types.contains("POISON")) {
            this.harvestables.add("poison barb");
        }
        if (this.types.contains("GROUND")) {
            this.habitats.add("mountain|sand|desert");
            this.harvestables.add("soft sand");
        }
        if (this.types.contains("STEEL")) {
            this.habitats.add("mountain");
            this.harvestables.add("metal coat");
        }
        if (this.types.contains("PSYCHIC")) {
            this.harvestables.add("psi energy");
        }
        if (this.types.contains("DARK")) {
            this.harvestables.add("dark energy");
        }
        if (this.types.contains("GHOST")) {
            this.habitats.add("gravestone|green12");
            this.harvestables.add("life force");
        }
        if (this.types.contains("FIGHTING")) {
            this.harvestables.add("binding band");
        }
        if (this.types.contains("FAIRY")) {
            this.harvestables.add("stardust");
        }
        if (name.equals("dratini") || name.equals("dragonair") || name.equals("dragonite")) {
            this.habitats.clear();
            this.habitats.add("water");
            this.harvestables.clear();
        }
        if (this.types.contains("DRAGON")) {
            this.harvestables.add("dragon fang");
            this.harvestables.add("dragon scale");
            this.harvestables.add("dragon scale");
            this.harvestables.add("dragon scale");
            this.harvestables.add("dragon scale");
        }
        if (this.types.contains("ICE")) {
            this.habitats.add("snow");
            this.harvestables.add("nevermeltice");
        }
        if (this.types.contains("ELECTRIC")) {
            this.harvestables.add("magnet");
        }
        if (name.equals("mareep") || name.equals("flaaffy") || name.equals("ampharos")) {
            this.harvestables.clear();
            this.harvestables.add("soft wool");
        } else if (name.equals("beedrill") || name.contains("combee") || name.equals("vespiquen") || name.equals("cutiefly") || name.equals("ribombee")) {
            this.harvestables.clear();
            this.harvestables.add("honey");
        } else if (name.equals("miltank")) {
            this.harvestables.clear();
            this.harvestables.add("moomoo milk");
        } else if (name.equals("delibird")) {
            this.harvestables.clear();
            this.harvestables.add("nevermeltice");
            this.harvestables.add("magnet");
            this.harvestables.add("ancientpowder");
            this.harvestables.add("soft wool");
            this.harvestables.add("moomoo milk");
            this.harvestables.add("hard stone");
            this.harvestables.add("manure");
            this.harvestables.add("berry juice");
            this.harvestables.add("soft sand");
            this.harvestables.add("dragon fang");
            this.harvestables.add("dragon scale");
            this.harvestables.add("life force");
            this.harvestables.add("psi energy");
            this.harvestables.add("dark energy");
            this.harvestables.add("metal coat");
            this.harvestables.add("silky thread");
            this.harvestables.add("hard shell");
            this.harvestables.add("soft feather");
            this.harvestables.add("charcoal");
            this.harvestables.add("grass");
            this.harvestables.add("honey");
        } else if (name.contains("unown")) {
            this.harvestables.clear();
            this.harvestables.add("ancientpowder");
            this.harvestTimerMax = EXTCreateContextRobustness.EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT;
        } else if (name.contains("regi")) {
            this.harvestables.add("ancientpowder");
        } else if (name.equals("mewtwo")) {
            this.harvestables.add("ancientpowder");
        } else if (name.equals("shuckle")) {
            this.harvestables.clear();
            this.harvestables.add("berry juice");
        } else if (name.equals("sableye")) {
            this.harvestables.clear();
            for (String itemName : Game.evoStones) {
                this.harvestables.add(itemName);
                this.harvestables.add("dark energy");
                this.harvestables.add("life force");
            }
        } else if (name.equals("applin") || name.equals("appletun")) {
            this.harvestables.add("sweet apple");
            this.harvestables.add("sweet apple");
            this.harvestables.add("sweet apple");
        } else if (name.equals("staryu") || name.equals("starmie")) {
            this.harvestables.add("star piece");
            this.harvestables.add("star piece");
        }
        if (this.habitats.size() <= 0) {
            this.habitats.add("green");
        }
        if (this.harvestables.size() <= 0) {
            this.harvestables.add("manure");
        }
    }
}
